from django.db import models

# Create your models here.

from django.contrib.auth.models import AbstractUser

from oauth.utils import generate_sign_openid


class User(AbstractUser):
    mobile = models.CharField(max_length=11,unique=True,verbose_name="手机号码")
    email_active = models.BooleanField(default=False,verbose_name="邮箱激活状态")
    class Meta:
        db_table = "tb_users"
    def __str__(self):
        return self.username

    def generate_verify_url(self):
        #组建一个token,并给token加密
        token = {"user_id":self.username,"email":self.email}
        token = generate_sign_openid(token)

        #生成一个验证连接
        verify_url = 'http://www.meiduo.site:8080/success_verify_email.html?token=' + token

        # 返回一个验证连接
        return verify_url
        pass
    pass